"""
Created on 2024/9/2 下午4:15
@author:刘飞
@description:
"""
from yc_django_utils.viewset import CustomModelViewSet
from yc_django_utils.filters import CoreModelFilterBackend
from ..utils.custom_permission import CustomPermission
from ..utils.data_level_permission_filter import DataLevelPermissionsFilter
from ..models import Post
from .post_serializers import PostSerializer, PostCreateUpdateSerializer


class PostViewSet(CustomModelViewSet):
    queryset = Post.objects.all()
    serializer_class = PostSerializer
    create_serializer_class = PostCreateUpdateSerializer
    update_serializer_class = PostCreateUpdateSerializer
    extra_filter_class = [CoreModelFilterBackend, DataLevelPermissionsFilter]
    permission_classes = [CustomPermission]
    search_fields = ["name", "code", "description", "status"]
